package chat02;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2024-09-13
 * Time: 9:15
 */
public class ReceiveMsg extends Thread {

    private Socket socket;

    public ReceiveMsg(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {

        while(true){
            InputStream inputStream = null;
            try {
                inputStream = socket.getInputStream();

                byte[] b = new byte[1024];

                int len;

                while((len=inputStream.read(b))!=-1) {
                    System.out.println(new String(b, 0, len));
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }


        }

    }
}
